<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <%@include file="/resources/datepicker/datepicker.jsp"%>
    <title><spring:message code="title.part"/></title>
    <script type="text/javascript">
        var datagrid;
        var message =$.messager;
        var operateDialog;

        $(function() {
            datagrid=$('#datagrid').datagrid({
                pageSize:20,
                pageList:[20],
                url : '${path}/business/supplier_quality/supplier_data/ajaxListBytwo.do',
                onLoadSuccess:function(){
                },
                queryParams: imonJYRH.serializeObject($("#tableForm *")),
                onBeforeLoad:function(){
                    if($('#supplierId').val()==''){
                        message.alert('<spring:message code='msg.tip'/>','请选择供应商！');
                        return false;
                    }
                },
                 rowStyler: function(index,row){
                    if (row['evaluationValue']<80){
                        return 'background-color:red';
                    }else if(row['evaluationValue']<90){
                        return 'background-color:yellow';
                    }else{
                        return 'background-color:green';
                    }
                }
            });
        });
        function search_() {
            datagrid.datagrid('unselectAll');
            datagrid.datagrid('load', imonJYRH.serializeObject($("#tableForm *")));
        }
        function reset_(){
            $("#tableForm *").each(function(){
                $(":input:not(:checkbox,:radio)",this).val("");
            });
        }
        function dialogSupplier_(){
            var href = '${path}/basedata/supplier/dialogUI.do';
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.dialog.choose'/>',
                width : 650,
                height : 400
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
        function dialogSupplierReturn(row){
            $("#supplierId").val(row['id']);
            $("#supplierCode").val(row['code']);
            $("#supplierName").val(row['name']);
            operateDialog.dialog('close');
        }
        function supplierData_(){
             var rows = datagrid.datagrid("getSelections");
              if(!isChooseOne(rows)){return;}
            var href = '${path}/business/supplier_quality/supplier_data/supplierDataUI.do?supplierId='+rows[0]['supplierId']+"&year="+rows[0]['year']+"&month="+rows[0]['month'];
            operateDialog = $("#operateDialog").dialog({
                title : '查看',
                width:1000,height:426
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
          
         }
           //判断选择单据是否是一条
        function isChooseOne(rows){
            var flag = false;
            if(rows.length >1 ) {
                message.show({
                    msg : "<spring:message code='msg.choose' arguments='"+rows.length+"'/>",
                    title : '<spring:message code='msg.tip'/>'
                });
                flag = false;
            } else if (rows.length == 0) {
                message.show({
                    msg : "<spring:message code='msg.please.choose'/>",
                    title : '<spring:message code='msg.tip'/>'
                });
                flag = false;
            }else{
                flag = true;
            }
            return flag;
        }
    </script>
</head>
<body class="easyui-layout">
<div data-options="region:'north'" style="overflow: hidden;height: 55px;">
    <div class="datagrid-toolbar" style="height: auto">
        <fieldset>
            <legend><spring:message code="label.condition"/></legend>
            <table id="tableForm" width="100%">
                <tr>
                    <td align="right"><spring:message code="label.year"/>：</td>
                    <td>
                        <input type="text" name="year" value="${year}" id="year"
                               onFocus="WdatePicker({isShowClear:false,isShowToday:false,dateFmt:'yyyy',readOnly:true})" class="field Wdate"/>
                    </td>
                    <td align="right"><spring:message code="label.supplier.code"/>：</td>
                    <td>
                        <input type="hidden" id='supplierId' name="supplierId"/>
                        <input type="text" id="supplierCode" onclick="dialogSupplier_();" readonly="true"/>
                    </td>
                    <td align="right"><spring:message code='label.supplier.name'/>:</td>
                    <td align="left">
                        <input type="text" id="supplierName" style="width: 180px;" disabled/>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
</div>
<div data-options="region:'center'">
    <div id="tb">
        <a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-search" onclick="search_();"><spring:message code="bar.command.search"/></a>
        <a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-star" onclick="supplierData_();">SupplierData供应商数据</a>
    </div>
    <table id="datagrid" toolbar="#tb" pagination="true" fit="true" nowrap="false" singleSelect="true">
        <thead>
        <tr>
            <th field="ck" checkbox="true"></th>
            <th field="supplierCode" width="80" align="center">SupplierCode<br/>供应商编码</th>
            <th field="supplierName" width="100" align="center">SupplierName<br/>供应商名称</th>
            <th field="year" width="80" align="center">Year<br/>年</th>
            <th field="month" width="100" align="center">Month<br/>月</th>
            <th field="evaluationValue" width="100" align="center">EvaluationValue<br/>总得分</th>
            <th field="qmSystem" width="100" align="center">QMSystem<br/>质量体系得分</th>
            <th field="processAudits" width="100" align="center">ProcessAudits<br/>过程审核得分</th>
            <th field="milesDeliveryQuality" width="140" align="center">0-MilesDeliveryQuality<br/>0公里交付质量得分</th>
            <th field="responseOnProblems" width="120" align="center">ResponseOnProblems<br/>问题反映进度得分</th>
            <th field="deductiblesForSpecialIncidents" width="200" align="center">DeductiblesForSpecialIncidents<br/>特殊投诉</th>
            <th field="environmentalManagementSystem" width="210" align="center">EnvironmentalManagementSystem(EMS)<br/>环境体系得分</th>
            <th field="supplierRating" width="120" align="center">SupplierRating<br/>供应商等级</th>
        </tr>
        </thead>
    </table>
</div>
<div id="operateDialog" class="easyui-dialog" style="width:880px;height:480px;"
     data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
    <iframe scrolling="auto" id='operateIFrame' frameborder="0"  src="" style="width:100%;height:100%;"/>
</div>
</body>
</html>